<!DOCTYPE html>
<html lang="en"><head>
    <title>CZH-DEV BLOG</title>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="format-detection" content="telephone=no" />
    <meta name="theme-color" content="#000084" />
    <link rel="icon" href="https://czh-dev.gitee.io/czh-blog.gitee.io//favicon.ico">
    <link rel="canonical" href="https://czh-dev.gitee.io/czh-blog.gitee.io/">
    
    
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"></button>
            <a class="brand" href="https://czh-dev.gitee.io/czh-blog.gitee.io/">CZH-DEV BLOG</a>
            <div class="nav-collapse collapse">
                <ul class="nav">
                    
                    
                        
                            <li>
                                <a href="/czh-blog.gitee.io/about/">
                                    
                                    <span>About</span>
                                </a>
                            </li>
                        
                    
                        
                            <li>
                                <a href="/czh-blog.gitee.io/post/">
                                    
                                    <span>All posts</span>
                                </a>
                            </li>
                        
                    
                        
                            <li>
                                <a href="/czh-blog.gitee.io/ebook/">
                                    
                                    <span>Resource</span>
                                </a>
                            </li>
                        
                    
                </ul>
            </div>
        </div>
    </div>
</nav><div id="content" class="container">
<div style="display: flex;">
  <div class="row-fluid navmargin">
    <div class="page-header">
      <h1>Spring Cloud Alibaba（Ⅸ） - Sat, Feb 11, 2023</h1>
    </div>
    <p class="lead"></p>
    <h1 id="第九章-配置中心-nacos-config">第九章 配置中心 Nacos Config</h1>
<h2 id="91-服务配置中心介绍">9.1 服务配置中心介绍</h2>
<p>首先我们来看一下,微服务架构下关于配置文件的一些问题：</p>
<ol>
<li>配置文件相对分散。在一个微服务架构下，配置文件会随着微服务的增多变的越来越多，而且分散</li>
</ol>
<p>在各个微服务中，不好统一配置和管理。</p>
<ol start="2">
<li>配置文件无法区分环境。微服务项目可能会有多个环境，例如：测试环境、预发布环境、生产环</li>
</ol>
<p>境。每一个环境所使用的配置理论上都是不同的，一旦需要修改，就需要我们去各个微服务下手动</p>
<p>维护，这比较困难。</p>
<ol start="3">
<li>配置文件无法实时更新。我们修改了配置文件之后，必须重新启动微服务才能使配置生效，这对一</li>
</ol>
<p>个正在运行的项目来说是非常不友好的。</p>
<p>基于上面这些问题，我们就需要<strong>配置中心</strong>的加入来解决这些问题。</p>
<p><strong>配置中心的思路是</strong>：</p>
<p>首先把项目中各种配置全部都放到一个集中的地方进行统一管理，并提供一套标准的接口。</p>
<p>当各个服务需要获取配置的时候，就来配置中心的接口拉取自己的配置。</p>
<p>当配置中心中的各种参数有更新的时候，也能通知到各个服务实时的过来同步最新的信息，使之动</p>
<p>态更新。</p>
<p>当加入了服务配置中心之后，我们的系统架构图会变成下面这样：</p>
<p><strong><img src="https://czh-pic.oss-cn-guangzhou.aliyuncs.com/202302111502162.png" alt="image-20201101222022206"></strong></p>
<h2 id="92-常见的服务配置中心">9.2 常见的服务配置中心</h2>
<ul>
<li><strong>Apollo</strong></li>
</ul>
<p>Apollo是由携程开源的分布式配置中心。特点有很多，比如：配置更新之后可以实时生效，支持灰</p>
<p>度发布功能，并且能对所有的配置进行版本管理、操作审计等功能，提供开放平台API。并且资料</p>
<p>也写的很详细。</p>
<ul>
<li><strong>Disconf</strong></li>
</ul>
<p>Disconf是由百度开源的分布式配置中心。它是基于Zookeeper来实现配置变更后实时通知和生效</p>
<p>的。</p>
<ul>
<li><strong>SpringCloud Confifig</strong></li>
</ul>
<p>这是Spring Cloud中带的配置中心组件。它和Spring是无缝集成，使用起来非常方便，并且它的配</p>
<p>置存储支持Git。不过它没有可视化的操作界面，配置的生效也不是实时的，需要重启或去刷新。</p>
<ul>
<li><strong>Nacos</strong></li>
</ul>
<p>这是SpingCloud alibaba技术栈中的一个组件，前面我们已经使用它做过服务注册中心。其实它也</p>
<p>集成了服务配置的功能，我们可以直接使用它作为服务配置中心。</p>
<h2 id="93-nacos-confifig入门">9.3 Nacos Confifig入门</h2>
<p>​	使用nacos作为配置中心，其实就是将nacos当做一个服务端，将各个微服务看成是客户端，我们</p>
<p>将各个微服务的配置文件统一存放在nacos上，然后各个微服务从nacos上拉取配置即可。</p>
<p>接下来我们以商品微服务为例，学习nacos confifig的使用。</p>
<ol>
<li>
<p>搭建nacos环境【使用现有的nacos环境即可】</p>
</li>
<li>
<p>在商品微服务中引入nacos的依赖</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-xml" data-lang="xml"><span style="display:flex;"><span><span style="color:#f92672">&lt;dependency&gt;</span>
</span></span><span style="display:flex;"><span>	<span style="color:#f92672">&lt;groupId&gt;</span>com.alibaba.cloud<span style="color:#f92672">&lt;/groupId&gt;</span>
</span></span><span style="display:flex;"><span>	<span style="color:#f92672">&lt;artifactId&gt;</span>spring-cloud-starter-alibaba-nacos-config<span style="color:#f92672">&lt;/artifactId&gt;</span> 
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;/dependency&gt;</span>
</span></span></code></pre></div></li>
<li>
<p>在微服务中添加nacos config的配置</p>
<p><strong>注意</strong>:不能使用原来的<code>application.yml</code>作为配置文件，而是新建一个<code>bootstrap.yml</code>作为配置文件</p>
<pre tabindex="0"><code>配置文件优先级(由高到低):
bootstrap.properties -&gt; bootstrap.yml -&gt; application.properties -&gt; application.yml
</code></pre><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">spring</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">application</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">name</span>: <span style="color:#ae81ff">product-service</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">cloud</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">nacos</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">config</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">server-addr</span>: <span style="color:#ae81ff">127.0.0.1</span>:<span style="color:#ae81ff">8848</span> <span style="color:#75715e">#nacos中心地址</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">file-extension</span>: <span style="color:#ae81ff">yaml</span> <span style="color:#75715e"># 配置文件格式</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">profiles</span>: 
</span></span><span style="display:flex;"><span>  	<span style="color:#f92672">active</span>: <span style="color:#ae81ff">dev</span> <span style="color:#75715e"># 环境标识</span>
</span></span></code></pre></div></li>
<li>
<p>在nacos中添加配置,然后把商品微服务application.yml配置复制到配置内容中.</p>
<p><strong><img src="https://czh-pic.oss-cn-guangzhou.aliyuncs.com/202302111502479.png" alt="image-20201102093026806"></strong></p>
<p><img src="%E5%9B%BE%E7%89%87/image-20201102095324857.png" alt="image-20201102095324857"></p>
</li>
<li>
<p>注释本地的application.yam中的内容， 启动程序进行测试</p>
</li>
<li>
<p>如果依旧可以成功访问程序，说明我们nacos的配置中心功能已经实现</p>
</li>
</ol>
<h2 id="94-配置动态刷新">9.4 配置动态刷新</h2>
<p>​	在入门案例中，我们实现了配置的远程存放，但是此时如果修改了配置，我们的程序是无法读取到的，因此，我们需要开启配置的动态刷新功能.</p>
<ol>
<li>
<p>在nacos中的product-service-dev.yaml配置项中添加下面配置:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">appConfig</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">name</span>: <span style="color:#ae81ff">product2020</span>
</span></span></code></pre></div></li>
<li>
<p>在商品微服务中新增NacosConfigControlller.java</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-java" data-lang="java"><span style="display:flex;"><span><span style="color:#a6e22e">@RestController</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">@RefreshScope</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">public</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">NacosConfigController</span> <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@Value</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;${appConfig.name}&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> String appConfigName<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@RequestMapping</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;/nacosConfig1&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">public</span> String <span style="color:#a6e22e">nacosConfig</span><span style="color:#f92672">(){</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;远程信息:&#34;</span><span style="color:#f92672">+</span>appConfigName<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div></li>
</ol>
<h2 id="95-配置共享">9.5 配置共享</h2>
<p>当配置越来越多的时候，我们就发现有很多配置是重复的，这时候就考虑可不可以将公共配置文件提取出来，然后实现共享呢？当然是可以的。接下来我们就来探讨如何实现这一功能。</p>
<ul>
<li><strong>同一个微服务的不同环境之间共享配置</strong></li>
</ul>
<p>如果想在同一个微服务的不同环境之间实现配置共享，其实很简单。只需要提取一个以 spring.application.name 命名的配置文件，然后将其所有环境的公共配置放在里面即可。</p>
<ol>
<li>
<p>新建一个名为product-service.yaml配置存放商品微服务的公共配置,把之前的公共配置都存放进去.</p>
<p><strong><img src="https://czh-pic.oss-cn-guangzhou.aliyuncs.com/202302111502137.png" alt="image-20201102101415390"></strong></p>
</li>
<li>
<p>新建一个名为product-service-test.yaml配置存放测试环境的配置</p>
<p><strong><img src="https://czh-pic.oss-cn-guangzhou.aliyuncs.com/202302111502824.png" alt="image-20201102102845484"></strong></p>
</li>
<li>
<p>新建一个名为product-service-dev.yaml配置存放测试环境的配置</p>
<p><strong><img src="https://czh-pic.oss-cn-guangzhou.aliyuncs.com/202302111502228.png" alt="image-20201102102132156"></strong></p>
</li>
<li>
<p>需要的配置信息具体如下:</p>
<p><strong><img src="https://czh-pic.oss-cn-guangzhou.aliyuncs.com/202302111502930.png" alt="image-20201102101627185"></strong></p>
</li>
<li>
<p>在NacosConfigController.java中新增如下逻辑</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-java" data-lang="java"><span style="display:flex;"><span><span style="color:#a6e22e">@RestController</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">@RefreshScope</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">public</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">NacosConfigController</span> <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@Value</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;${appConfig.name}&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> String appConfigName<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@Value</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;${env}&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> String env<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@RequestMapping</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;/nacosConfig1&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">public</span> String <span style="color:#a6e22e">nacosConfig</span><span style="color:#f92672">(){</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;远程信息:&#34;</span><span style="color:#f92672">+</span>appConfigName<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@RequestMapping</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;/nacosConfig2&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">public</span> String <span style="color:#a6e22e">nacosConfig2</span><span style="color:#f92672">(){</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;公共配置:&#34;</span><span style="color:#f92672">+</span>appConfigName<span style="color:#f92672">+</span><span style="color:#e6db74">&#34;,环境配置信息:&#34;</span><span style="color:#f92672">+</span>env<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div></li>
<li>
<p>通过修改环境，参看是否可以读取公共配置和环境独有配置</p>
<p><strong><img src="https://czh-pic.oss-cn-guangzhou.aliyuncs.com/202302111502924.png" alt="image-20201102102314702"></strong></p>
</li>
</ol>
<ul>
<li><strong>不同微服务中间共享配置</strong></li>
</ul>
<p>不同为服务之间实现配置共享的原理类似于文件引入，就是定义一个公共配置，然后在当前配置中引</p>
<p>入。</p>
<ol>
<li>在nacos中定义一个DataID为global-config.yaml的配置，用于所有微服务共享</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">globalConfig</span>: <span style="color:#ae81ff">global</span>
</span></span></code></pre></div><p><strong><img src="https://czh-pic.oss-cn-guangzhou.aliyuncs.com/202302111502646.png" alt="image-20201102103412474"></strong></p>
<ol start="2">
<li>修改bootstrap.yaml</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">spring</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">application</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">name</span>: <span style="color:#ae81ff">product-service</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">cloud</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">nacos</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">config</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">server-addr</span>: <span style="color:#ae81ff">127.0.0.1</span>:<span style="color:#ae81ff">8848</span> <span style="color:#75715e">#nacos中心地址</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">file-extension</span>: <span style="color:#ae81ff">yaml</span> <span style="color:#75715e"># 配置文件格式</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">shared-configs</span>:
</span></span><span style="display:flex;"><span>          - <span style="color:#f92672">data-id</span>: <span style="color:#ae81ff">global-config.yaml</span> <span style="color:#75715e"># 配置要引入的配置</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">refresh</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">profiles</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">active</span>: <span style="color:#ae81ff">test</span> <span style="color:#75715e"># 环境标识</span>
</span></span></code></pre></div><ol start="3">
<li>
<p>在NacosConfigController.java中新增一个方法</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-java" data-lang="java"><span style="display:flex;"><span><span style="color:#a6e22e">@RestController</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">@RefreshScope</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">public</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">NacosConfigController</span> <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@Value</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;${appConfig.name}&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> String appConfigName<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@Value</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;${env}&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> String env<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@Value</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;${globalConfig}&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> String globalConfig<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@RequestMapping</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;/nacosConfig1&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">public</span> String <span style="color:#a6e22e">nacosConfig</span><span style="color:#f92672">(){</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;远程信息:&#34;</span><span style="color:#f92672">+</span>appConfigName<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@RequestMapping</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;/nacosConfig2&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">public</span> String <span style="color:#a6e22e">nacosConfig2</span><span style="color:#f92672">(){</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;公共配置:&#34;</span><span style="color:#f92672">+</span>appConfigName<span style="color:#f92672">+</span><span style="color:#e6db74">&#34;,环境配置信息:&#34;</span><span style="color:#f92672">+</span>env<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@RequestMapping</span><span style="color:#f92672">(</span><span style="color:#e6db74">&#34;/nacosConfig3&#34;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">public</span> String <span style="color:#a6e22e">nacosConfig3</span><span style="color:#f92672">(){</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;全局配置:&#34;</span><span style="color:#f92672">+</span>globalConfig<span style="color:#f92672">+</span><span style="color:#e6db74">&#34;,公共配置:&#34;</span><span style="color:#f92672">+</span>appConfigName<span style="color:#f92672">+</span><span style="color:#e6db74">&#34;,环境配置信息:&#34;</span><span style="color:#f92672">+</span>env<span style="color:#f92672">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div></li>
<li>
<p>重启服务并测试.</p>
</li>
</ol>

    <h4><a href="https://czh-dev.gitee.io/czh-blog.gitee.io/">Back to Home</a></h4>
  </div>

  <div class="span3 bs-docs-sidebar" style="position:fixed;right: 40px;top: 50px;">
    <h1>catalogue</h1>
    <ul class="nav nav-list bs-docs-sidenav">
      <div class="toc-div">
        <nav id="TableOfContents">
  <ul>
    <li><a href="#91-服务配置中心介绍">9.1 服务配置中心介绍</a></li>
    <li><a href="#92-常见的服务配置中心">9.2 常见的服务配置中心</a></li>
    <li><a href="#93-nacos-confifig入门">9.3 Nacos Confifig入门</a></li>
    <li><a href="#94-配置动态刷新">9.4 配置动态刷新</a></li>
    <li><a href="#95-配置共享">9.5 配置共享</a></li>
  </ul>
</nav>
      </div>
    </ul>
  </div>

</div>
<script src="https://cdn.jsdelivr.net/npm/gumshoejs@5.1.2/dist/gumshoe.min.js"></script>
<script>
  var spy = new Gumshoe('#TableOfContents a', {
    nested: true,
    nestedClass: 'active'
  });
</script>
<style>
   
  #TableOfContents li,
  #TableOfContents ul {
    list-style-type: none;
  }

  #TableOfContents ul {
    padding-left: 0px;
  }

  #TableOfContents li>a {
    display: block;
    padding: 4px 20px;
    font-size: 95%;
    color: #000000;
  }

  #TableOfContents li>a:hover,
  #TableOfContents li>a:focus {
    padding-left: 19px;
    color: #3A6bA5;
    text-decoration: none;
    background-color: transparent;
    border-left: 1px solid #3A6bA5;
  }

  #TableOfContents li.active>a,
  #TableOfContents li.active>a:hover,
  #TableOfContents li.active>a:focus {
    padding-left: 18px;
    font-weight: bold;
    color: #3A6bA5;
    background-color: transparent;
    border-left: 2px solid #3A6bA5;
  }

   
  #TableOfContents li>ul {
    padding-bottom: 10px;
  }

  #TableOfContents li li>a {
    padding-top: 1px;
    padding-bottom: 1px;
    padding-left: 30px;
    font-size: 14px;
    font-weight: normal;
  }

  #TableOfContents li li>a:hover,
  #TableOfContents li li>a:focus {
    padding-left: 29px;
  }

  #TableOfContents li li.active>a,
  #TableOfContents li li.active>a:hover,
  #TableOfContents li li.active>a:focus {
    padding-left: 28px;
    font-weight: 500;
  }

  #TableOfContents .nav-link.active+ul {
    display: block;
  }

  #TableOfContents li>ul {
    display: none;
  }

  #TableOfContents li.active>ul {
    display: inherit;
  }

  .toc-div {
    position: -webkit-sticky;
     
    position: sticky;
     
    top: 20px;
  }
</style>


        </div><footer class="container">
    <hr class="soften">
    <p>
    <a href="https://space.bilibili.com/1799809923">Love eating fried pork ribs</a> | 

&copy; 
<a href="http://jmf-portfolio.netlify.com" target="_blank">
    JM Fergeau
</a>
<span id="thisyear">2023</span>

    | My site


        | Built on <a href="//gohugo.io" target="_blank">Hugo</a>

</p>
    <p class="text-center">
        <a href="https://facebook.com">Facebook</a> 
        <a href="https://twitter.com">Twitter</a> 
        <a href="https://linkedin.com">Linkedin</a> 
        <a href="https://github.com">GitHub</a> 
        <a href="https://gitlab.com">GitLab</a>
    </p>
</footer>

</body><link rel="stylesheet" href="/czh-blog.gitee.io/css/bootstrap.css">
<link rel="stylesheet" href="/czh-blog.gitee.io/css/bootstrap-responsive.css">
<link rel="stylesheet" href="/czh-blog.gitee.io/css/style.css">

<script src="/czh-blog.gitee.io/js/jquery.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-386.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-transition.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-alert.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-modal.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-dropdown.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-scrollspy.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-tab.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-tooltip.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-popover.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-button.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-collapse.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-carousel.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-typeahead.js"></script>
<script src="/czh-blog.gitee.io/js/bootstrap-affix.js"></script>
<script>
    _386 = { 
        fastLoad: false ,
        onePass: false , 
        speedFactor: 1 
    };

    
    function ThisYear() {
        document.getElementById('thisyear').innerHTML = new Date().getFullYear();
    };
</script>
</html>
